//
//  YXImageData+Internal.h
//  YXImageBrowserDemo
//
//  Created by guo peng huang on 2021/5/17.
//

#import "YXImageData.h"

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, YXImageLoadingStatus) {
    YXImageLoadingStatusNone,
    YXImageLoadingStatusCompressing,
    YXImageLoadingStatusDecoding,
    YXImageLoadingStatusQuerying,
    YXImageLoadingStatusProcessing,
    YXImageLoadingStatusDownloading,
    YXImageLoadingStatusReadingPHAsset,
};

@class YXImageData;

@protocol YXImageDataDelegate <NSObject>
@required

- (void)yx_imageData:(YXImageData *)data startLoadingWithStatus:(YXImageLoadingStatus)status;

- (void)yx_imageIsInvalidForData:(YXImageData *)data;

- (void)yx_imageData:(YXImageData *)data readyForImage:(__kindof UIImage *)image;

- (void)yx_imageData:(YXImageData *)data readyForThumbImage:(__kindof UIImage *)image;

- (void)yx_imageData:(YXImageData *)data readyForCompressedImage:(__kindof UIImage *)image;

- (void)yx_imageData:(YXImageData *)data downloadProgress:(CGFloat)progress;

- (void)yx_imageDownloadFailedForData:(YXImageData *)data;

@end

@interface YXImageData ()

@property (nonatomic, weak) id<YXImageDataDelegate> delegate;

/// The status of asynchronous tasks.
@property (nonatomic, assign) YXImageLoadingStatus loadingStatus;

/// The origin image.
@property (nonatomic, strong) UIImage *originImage;

/// The image compressed by 'originImage' if need.
@property (nonatomic, strong) UIImage *compressedImage;

- (BOOL)shouldCompress;

- (void)cuttingImageToRect:(CGRect)rect complete:(void(^)(UIImage * _Nullable image))complete;

@end

NS_ASSUME_NONNULL_END
